//////////////////////////////////////////////////////////////////////////////
//                                                                          //
//     Filename: Shue.h ( FORCED HANDS DEBUG VERSION )                      //
//                                                                          //
//      WARNING DO NOT COMPILE INTO MAIN APPLICATION !!!!!                  //
//                                                                          //
//////////////////////////////////////////////////////////////////////////////
//                                                                          //
//  Description: This file implements the Shue class, which encapulates     //
//                1 or more decks of cards to be used in our games.         //
//                                                                          //
//////////////////////////////////////////////////////////////////////////////
//       Copyright (c) 2006 - Realtime Gaming.  All rights reserved.        //
//////////////////////////////////////////////////////////////////////////////

#ifndef SHUE_H
#define SHUE_H

#include "r250.h"

class CardMgr;
class Shue;

#ifdef FORCEDSHOE
  class ODBCPool;
  class ODBCConnection;
#endif // FORCEDSHOE

//////////////////////////////////////////////////////////////////////////////
// ShueSave class
//
// This class is used when saving the state of a game to the database.
//////////////////////////////////////////////////////////////////////////////
class ShueSave
{
    //
    // numdecks & cardmgr are assumed the same as when the Shue was created
    //
    public:
        int32 next;
        uint32 seed;
};

///////////////////////////////////////////////////////////////////////////////////
// ShueGameInfo class
//
// This class is used to pass the shue info about the game it is being created for
///////////////////////////////////////////////////////////////////////////////////
class ShueGameInfo
{
public:
    #ifndef FORCEDSHOE 
    int32 gameId;
    uint8 machId;
    #else
    ShueGameInfo();

    int32 gameId;
    uint8 machId;
    String pid;
    int32 shueMinSize;
    #endif
    
};

//////////////////////////////////////////////////////////////////////////////
// Shue class
//////////////////////////////////////////////////////////////////////////////
class Shue
{
    public:
        Shue(CardMgr* pMgr, int32 numDecks, const ShueGameInfo &gameInfo);
        ~Shue();

        uint8 getCard();
        uint8 lookAtCard(int32 index);

        bool8 pushBackNCards(int32 n);

        void shuffle();
        void shuffle(uint32 Seed);
      

        void save(ShueSave*);
        void restore(ShueSave*);

        int32 getNumDecks();
        int32 getNumCards();
        int32 getNumCardsLeft();

    protected:
        void fresh();
        void swap( uint8& a, uint8& b );

#ifdef FORCEDSHOE
		uint8 encodeCard( uint16 nSuit, uint16 nRank );
#endif // FORCEDSHOE

    protected:
        CardMgr*        m_pMgr;
        ShueGameInfo    m_GameInfo;
        uint8*            m_pDeck;
        int32             m_nCount;
        int32            m_nNext;
        uint32            m_nSeed;
        bool8            m_bInfinite;
        R250            m_oR250;

#ifdef FORCEDSHOE
		ODBCPool*       m_pDBPool;
        ODBCConnection* m_pDBConn;
        uint32          m_nNumDecks;
        bool8            m_bDebugShueLoaded;
#endif // FORCEDSHOE
};

#endif


